package com.spring.bean.config;

import com.spring.bean.service.IPeople;
import com.spring.bean.service.People;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.lang.NonNull;

/**
 * 每一行代码，都是改变世界的力量
 *
 * @author 郭帅
 * @date 2021/11/1 11:23 下午
 */
@Configuration
//@Import({AppConfig2.class, ThirdMockImportSelector.class, MyImportBeanDefinitionRegistrar.class})
public class AppConfig {

    @Bean
    public IPeople people() {
        return new People();
    }
//    @Bean
//    public BeanDefinitionRegistryPostProcessor people() {
//        return new BeanDefinitionRegistryPostProcessor() {
//
//            @Override
//            public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
//                System.out.println("----- postProcessBeanFactory -----");
//            }
//
//            @Override
//            public void postProcessBeanDefinitionRegistry(@NonNull BeanDefinitionRegistry registry) throws BeansException {
//                BeanDefinitionBuilder beanBuilder = BeanDefinitionBuilder.genericBeanDefinition(People.class, People::new);
//                registry.registerBeanDefinition("people", beanBuilder.getBeanDefinition());
//            }
//        };
//    }

}
